<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">提交</button>
    <script>
        let btn = document.getElementById('btn')    

        let handle = function (e,x,y) {
                console.log('提交',e,x+y);
                
        }
        btn.addEventListener('click', throttle(handle, 1000))

        function debounce (fn,dely) {
           let timer = null
           return function (...args) {
            clearTimeout(timer)
             timer= setTimeout(() => {
                fn.call(this,...args)
             }, dely);
           }
        }

        function throttle (fn,dely) {
            let pre = Date.now()
            return function (...args) {
                let now = Date.now()
                if (now - pre >= dely) {
                    fn.call(this,...args)
                    pre = now
                }

            } 
        }


    </script>
</body>
</html>
